<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">
    <title>WeIn--登录</title>
    <link rel="shortcut icon" href="backstage/img/logo-title.png">
    <!-- global stylesheets -->
    <!--<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">-->
    <link rel="stylesheet" href="backstage/css/bootstrap.min.css">
    <link rel="stylesheet" href="backstage/css/sucaijiayuan.css">
    <link rel="stylesheet" href="backstage/css/style.default.css" id="theme-stylesheet">

    <!-- Core stylesheets -->
    <link rel="stylesheet" href="backstage/css/style.css">
    <link rel="stylesheet" href="backstage/css/login.css">
</head>
<body>


<section>
    <div class="am-g am-g-collapse am-index-video-div">
        <img src="img/top.jpg" style="position:fixed;z-index:-999;" width="100%" class="am-index-img am-show-lg-down">
        <!--header navbar-->
        <header class="header">
            <nav class="navbar navbar-expand-lg" style="background:none;box-shadow: 0 0 0 0;">
                <div class="container">
                    <div class="navbar-holder d-flex align-items-center justify-content-between">
                        <div class="navbar-header">
                            <a href="index.jsp" class="navbar-brand">
                                <div class="brand-text brand-big hidden-lg-down"><img src="backstage/img/logo.png" alt="Logo" class="logo-img"></div>
                                <div class="brand-text brand-small"><img src="backstage/img/logo-min.png" alt="Logo" style="height: 30px;width:30px;margin-left: 5px;"></div>
                            </a>
                        </div>
                    </div>
                    <ul class="nav-menu list-unstyled d-flex flex-md-row align-items-md-center">
                        <li class="nav-item d-flex align-items-center">
                            <a class="nav-link" href="index.jsp">首页</a>
                        </li>
                        <li class="nav-item d-flex align-items-center">
                            <a class="nav-link" href="Courses.jsp">相关课程</a>
                        </li>
                        <li class="nav-item d-flex align-items-center">
                            <a class="nav-link" href="Teachers.jsp">师资力量</a>
                        </li>
                        <li class="nav-item d-flex align-items-center">
                            <a class="nav-link" href="SudentWorks.jsp">学员作品</a>
                        </li>
                        <li class="nav-item d-flex align-items-center" style="margin-right: 70px;">
                            <a class="nav-link" href="Recruit.jsp">人才招聘</a>
                        </li>

                        <li class="nav-item d-flex align-items-center">
                            <a class="nav-link" href="login.html">登录</a>
                        </li>
                        <li class="nav-item d-flex align-items-center">
                            <a class="nav-link" href="register.html">注册</a>
                        </li>
                        <!--<li class="nav-item dropdown"><a id="profile" class="nav-link logout" data-target="#" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><img src="img/avatar-1.jpg" alt="..." class="img-fluid rounded-circle" style="height: 30px; width: 30px;"></a>
                            <ul aria-labelledby="profile" class="dropdown-menu profile">
                                <li>
                                    <a rel="nofollow" href="#" class="dropdown-item d-flex">
                                        <div class="msg-profile"> <img src="backstage/img/avatar-1.jpg" alt="..." class="img-fluid rounded-circle"></div>
                                        <div class="msg-body">
                                            <h3 class="h5">Steena Ben</h3><span>steenaben@Businessbox.com</span>
                                        </div>
                                    </a>
                                    <hr>
                                </li>
                                <li>
                                    <a rel="nofollow" href="profile.html" class="dropdown-item">
                                        <div class="notification">
                                            <div class="notification-content"><i class="fa fa-user "></i>个人信息</div>
                                        </div>
                                    </a>
                                </li>
                                <li>
                                    <a rel="nofollow" href="profile.html" class="dropdown-item">
                                        <div class="notification">
                                            <div class="notification-content"><i class="fa fa-power-off"></i>退出</div>
                                        </div>
                                    </a>
                                </li>
                            </ul>
                        </li>-->
                    </ul>
                </div>
            </nav>
        </header>
        <div class="box" style="margin-top: 90px;">
            <div class="box-small">
                <h4 class="title">账户登录</h4>
                    <div class="form-group">
                        <input type="text" name="name"  class="form-control login_input" placeholder=" 用户名" required/>
                        <div class="showsIcon" style="background-image: url(img/user.png);"></div>
                    </div>
                    <div class="form-group">
                        <input type="password" name="password" class="form-control login_input" placeholder=" 密码" required/>
                        <div class="showsIcon" style="background-image: url(img/pwd.png);width: 28px;height: 28px;left: 3px;"></div>
                    </div>
                    <div class="form-group">
                        <input class="captcha_input login_input" type="text" required name="captcha" placeholder="请输入图片中的验证码" style="margin-right: 23px;">
                        <img id="captcha" src="/codeServlet"  onclick="this.src='/codeServlet?'+new Date().getTime();" width="100" height="40"><br/>
                    </div>
                    <div class="form-group">
                        <button id="btn-submit" data-toggle="modal" data-target="#myModal" class="btn btn-primary btn-block">登录</button>
                    </div>
            </div>
            <div class="box-bottom">
                <span style="margin-left: 60px;">第三方登录：</span>
                <a href="https://cas.dgut.edu.cn?appid=javaee&state=STATE" title="莞工登录"><img src="img/dgut.png" alt="莞工"></a>
                <span style="margin-left: 80px;"><a href="register.html" style="text-decoration: none;color:blue;" title="立即注册">立即注册</a></span>
            </div>
        </div>
    </div>
</section>
<footer style="width: 100%;height: 70px;position:fixed;bottom: 0;background: #1a1f2a;color:#838383;">
    <p style="text-align:center;line-height: 70px;">
        Copyright @ 李剑波、陈伯瑞
        <a href="backstage/login.jsp" style="margin-left: 100px;color:#FFF;">后台登录</a>
    </p>
</footer>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="myModalLabel">
                    登录信息提示
                </h5>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
            </div>
            <div class="modal-body" style="text-align: center;font-size: 18px;">
                所有的输入都不能为空！！！请检查一下
            </div>
            <div class="modal-footer">
                <button id="dismiss" type="button" class="btn btn-default" data-dismiss="modal" style="display: inline-block;">确定
                </button>
                <a href="" id="toLogin" class="btn btn-primary" style="display: none;">确定</a>
            </div>
        </div>
    </div>
</div>
</body>
</html>
<!--Global Javascript -->
<script src="backstage/js/jquery.min.js"></script>
<script src="backstage/js/popper/popper.min.js"></script>
<script src="backstage/js/tether.min.js"></script>
<script src="backstage/js/bootstrap.min.js"></script>
<script src="backstage/js/jquery.cookie.js"></script>
<script src="backstage/js/jquery.validate.min.js"></script>
<script src="backstage/js/chart.min.js"></script>
<script src="backstage/js/front.js"></script>
<script>
    //判断字符是否为空的方法
    function notEmpty(obj){
        if(typeof obj == "undefined" || obj == null || obj == ""){
            return false;
        }else{
            return true;
        }
    }
    $(function () {
        $("#btn-submit").click(function () {
            var input = $(".login_input");
            //全部数据都不为空时，才发送数据
            if(notEmpty(input.eq(0).val())&&notEmpty(input.eq(1).val())&&notEmpty(input.eq(2).val())){
                $.ajax({
                    type: 'GET',
                    url: '/FrontLocalLogin',
                    data: {user:input.eq(0).val(),passwd:input.eq(1).val(),captcha:input.eq(2).val()},
                    contentType: 'text/json,charset=utf-8',
                    dataType: 'json',
                    success: function (data) {
                        var flag = data.flag;
                        if(flag==0){
                            $(".modal-body").text("登录成功！！");
                            $("#dismiss").css("display","none");
                            $("#toLogin").css("display","inline-block");
                            var url = document.referrer;
                            if(url.search("login.html")!=-1||url.search("register.html")!=-1){
                                url = "/index.jsp";
                            }
                            console.log(url);
                            $("#toLogin").attr("href",url);
                            $("#myModal").click(function () {
                                window.location.href = url;
                            });
                        }else if(flag==1){
                            $(".modal-body").text("用户名/密码输入错误！！");
                            $("#dismiss").css("display","inline-block");
                            $("#toLogin").css("display","none");
                        }else if(flag==2){
                            $(".modal-body").text("验证码输入错误！！");
                            $("#dismiss").css("display","inline-block");
                            $("#toLogin").css("display","none");
                            $(".captcha_input").val("");
                            $("#captcha").attr("src","/codeServlet?"+new Date().getTime());
                        }else {
                            alert("服务器错误！！");
                        }
                    }
                });
            }

        });
    });
</script>
